package com.woniuxy02;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-05-23 14:03
 */
public class Test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入一个数");
        int numA = sc.nextInt();
        System.out.println("输入一个数");
        int numB = sc.nextInt();
        System.out.println("输入一个运算符+ - * /");
        String opeartor = sc.next();
        int result =0 ;
        //oprFlag：ture，运算符有效；false代表无效
        boolean oprFlag=true;
        //zeroFlag:ture--0,false--非0
        boolean zeroFlag=false;
        switch (opeartor) {
            case "+":
                result = numA + numB;
                break;
            case "-":
                result = numA - numB;
                break;
            case "*":
                result = numA * numB;
                break;
            case "/":
                if (numB!=0) {
                    result = numA / numB;
                }else{
                    zeroFlag=true;
                }
                break;
            default:
                oprFlag=false;
                break;
        }

        if (zeroFlag) {
            System.out.println("除数为0，无法计算");
        }else if(oprFlag) {
            System.out.println(numA+opeartor+numB+"="+result);
        }else{
            System.out.println("运算符错误，无法计算");
        }
    }
}
